home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
cmln0286.arc
/
EXOTIC4.LTG
< prev
next >
Wrap
Text File
|
1986-02-03
|
2KB
|
105 lines
Listing 4
define(TPI,6.2831853072)
subroutine fftdif(x,y,m) #Decimation in frequency FFT--reorder output
#Forward transform (negative exponential)
#Arguments:
# x Real input/output array
# y Imaginary input/output array
# m Dimension of x and y is 2**m
dimension x(1),y(1)
n=2**m
kjj=n
do k=1,m
{
nn=kjj
kjj=kjj/2
dthet=TPI/nn
do j=1,kjj
{
thet=(j-1)*dthet
c=cos(thet)
s=sin(thet)
do i1=j,n,nn
{
j1=i1+kjj
xs=x(i1)-x(j1)
ys=y(i1)-y(j1)
x(i1)=x(i1)+x(j1)
y(i1)=y(i1)+y(j1)
x(j1)=xs*c+ys*s
y(j1)=-xs*s+ys*c
}
}
}
call reordr(x,y,m)
return
end
subroutine fftdit(x,y,m) #Decimation in time FFT--reorder input
#Back transform (Positive exponential)
#Arguments:
# x Real input/output array
# y Imaginary input/output array
# m Dimension of x and y is 2**m
dimension x(1),y(1)
call reordr(x,y,m)
n=2**m
nn=1
do k=1,m
{
kjj=nnè nn=nn+nn
dthet=TPI/nn
do j=1,kjj
{
thet=(j-1)*dthet
c=cos(thet)
s=sin(thet)
do i1=j,n,nn
{
j1=i1+kjj
xs=x(j1)*c-y(j1)*s
ys=x(j1)*s+y(j1)*c
x(j1)=x(i1)-xs
y(j1)=y(i1)-ys
x(i1)=x(i1)+xs
y(i1)=y(i1)+ys
}
}
}
return
end
subroutine reordr(x,y,m) #Reorders data for FFT input or output
#Arguments:
# x Real input/output array
# y Imaginary input/output array
# m Dimension of x and y is 2**m
dimension x(1),y(1)
n=2**m
do i=1,n
{
k=i-1 #Reverse-bit k to form j-1
j=1
ib=n
do l=1,m #Add bits to j-1 from top down where bits exist in k from bottom up
{
ib=ib/2
kn=k/2
j=j+(k-kn*2)*ib
k=kn
}
if(j>i) #Interchange and conjugate array elements if j>i
{
q=x(j)
x(j)=x(i)
x(i)=q
q=y(j)
y(j)=-y(i)
y(i)=-q
}
else if(i==j) #Conjugate only if j==i
y(i)=-y(i)
} #No action if j<i; elements already reordered
return
end
è